package com.gotop.common.utils.provider;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

/**
 * @program: cem
 * @description:
 * @author: superfish
 * @create: 2020-12-21 17:29
 **/
@Service
public class ClientDetailsServiceImpl implements IClientDetailsService {

    private final JdbcTemplate jdbcTemplate;

    public IClientDetails loadClientByClientId(String clientId) {
        try {
            return (IClientDetails) this.jdbcTemplate.queryForObject("select client_id, client_secret, access_token_validity, refresh_token_validity from system_client where client_id = ? and type = 0", new String[]{clientId}, new BeanPropertyRowMapper(ClientDetails.class));
        } catch (Exception var3) {
            return null;
        }
    }

    public ClientDetailsServiceImpl(final JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }
}
